// OUTDOOR SECTION SCRIPT
//    Section: X = 3, Y = 1

// This is the special encounter script for this town.
// The states INIT_STATE and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

beginoutdoorscript;

variables;

short choice;

body;

beginstate INIT_STATE;
// This state called whenever this section is loaded into memory.
//	if (get_flag(231, 0) == 0) {
//		set_flag(231, 0, 1);
//	}
break;

beginstate START_STATE;
// Starting state of the section, called every turn the party 
// stands inside this section until you change the state.
break;

beginstate 10;
	if (get_flag(231, 0) > 0) {
		// you know a passage to Avernum is around here someplace...
		if (get_flag(231, 1) == 0) {
			set_flag(231, 1, 1);
			message_dialog("As you are walking past the cliff over the ruins of a house, you notice something funny about the west cliff face.", "It appears as if you can slip through a large crack.  Without knowing about it, you would have missed it.");
		}
		if (get_terrain(37, 39) != 55) {
			set_terrain(37, 39, 55);
		}
	}
	else {
		if (get_flag(231, 3) == 0) {
			set_flag(231, 3, 1);
			message_dialog("Strange, there are the ruins of a large house here that doesn't appear to be a homestead or farmhouse.", "Why would a large house be built in the middle of nowhere?");
		}
	}
break;

beginstate 11;
	if (get_flag(231, 2) == 0) {
		set_flag(231, 2, 1);
		message_dialog("You scramble through the crack and pop out on the other side.", "Before you lies a long passage down to what appears to be a cave entrance.");
	}
	// you're already in, make sure you can get out...
	if (get_terrain(37, 39) != 55) {
		set_terrain(37, 39, 55);
	}
break;
